import { App } from 'vue'
import Layouts from './src/components/Layout/index'
import { PureWhiteLayout, TagsView } from './src/components/Layout/index'
import ParentView from './src/components/ParentView/index.vue'
import InnerLink from './src/components/InnerLink/index.vue'
import NotFoundPage from './src/components/Error/404.vue'
import Login from './src/components/Login/index.vue'
import CommonTable from './src/components/CommonTable/index.vue'
import CommonTreeBox from './src/components/CommonTreeBox/index.vue'
import Pagination from './src/components/Pagination/index.vue'
import CommonEditDialog from './src/components/CommonEditDialog/index.vue'
import CommonSearchBox from './src/components/CommonSearchBox/index.vue'
import RightToolBar from './src/components/RightToolBar/index.vue'
import Loading from './src/components/Loading/index'
import ImageUpload from './src/components/ImageUpload/index.vue'
import FileUpload from './src/components/FileUpload/index.vue'
import Editor from './src/components/Editor/index.vue'
import CommonCurdTemplate from './src/components/CommonCurdTemplate/index.vue'
import Redirect from './src/components/Redirect/index.vue'
import SvgIcon from '@/components/IconSelect/SvgIcon.vue'
// 引入element-ui
import ElementPlus from 'element-plus'
// 中文
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import 'element-plus/dist/index.css'
// 切换element样式
import 'element-plus/theme-chalk/dark/css-vars.css'
// 全局注册element的组件
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
//svg插件需要配置代码
import "virtual:svg-icons-register"

interface LoginRef extends InstanceType<typeof Login> {
  loginError(): void
}

export type * from './src/types'

export {
  TagsView,
  PureWhiteLayout,
  Login,
  LoginRef,
  ParentView,
  InnerLink,
  NotFoundPage,
  CommonTable,
  CommonTreeBox,
  Pagination,
  CommonEditDialog,
  CommonSearchBox,
  RightToolBar,
  ImageUpload,
  FileUpload,
  Editor,
  CommonCurdTemplate,
  Redirect,
}

const component = [...Layouts];

const gykUI = {
  install(app: App) {
    component.forEach((item) => {
      // 注册为全局组件
      app.component(item.name, item);
      // 注册svg图标组件
      app.component('svg-icon', SvgIcon);
      // 字体图标引入（全局注册）
      for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
        app.component(key, component)
      }
      app.use(ElementPlus, {
        locale: zhCn,
      });
      // 注入全局loading
      app.use(Loading);
    });
  },
}

export default gykUI
